package com.sk.photo_album.util;

import android.graphics.Rect;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class SpacesItemDecoration extends RecyclerView.ItemDecoration {
    private int top;
    private int bottom;

    private int right;
    private int left;

    public SpacesItemDecoration(int bottom, int left, int top, int right) {
        this.top = top;
        this.right = right;
        this.bottom = bottom;
        this.left = left;
    }

    @Override
    public void getItemOffsets(Rect outRect, @NonNull View view,
                               RecyclerView parent, @NonNull RecyclerView.State state) {
        outRect.left = left;
        outRect.right = right;
        outRect.bottom = bottom;
        outRect.top = top;
        // Add top margin only for the first item to avoid double space between items
//        if (parent.getChildAdapterPosition(view) == 0) {
//            outRect.left = left;
//            outRect.right = right;
//            outRect.bottom = bottom;
//        } else {
//            outRect.left = left;
//            outRect.right = right;
//            outRect.bottom = bottom;
//            outRect.top = top;
//        }
    }
}
